package arsw.twitter.servidor;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import arsw.twitter.common.IControllerRemote;

public class Servidor {
	
	public static void main(String[] args) {
		String addr;
		
		try {
			addr = InetAddress.getLocalHost().getHostAddress();
			System.err.println("Inicia Servidor: "+ addr +"!");
			
			ControllerRemote controlador 	= ControllerRemote.getInstance();
			IControllerRemote stub 			= (IControllerRemote) UnicastRemoteObject.exportObject(controlador,0);
			LocateRegistry.createRegistry(2000);
			Registry registry 				= LocateRegistry.getRegistry(2000);
			registry.bind(IControllerRemote.ControllerBindName, stub);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (AlreadyBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (UnknownHostException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
}
